package team.seekers.hula.teamwork.tag.controller;


import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.auth.service.MindUtils;
import team.seekers.hula.teamwork.tag.entity.dto.TagAddDTO;
import team.seekers.hula.teamwork.tag.entity.dto.TagUpdateDTO;
import team.seekers.hula.teamwork.tag.entity.vo.TagListVO;
import team.seekers.hula.teamwork.tag.service.TagService;

import java.util.List;

/**
 * 待办标签表 前端控制器
 * @author hbc
 * @since 2021-09-03
 */
@Controller
@ApiResponseBody
@RequestMapping("/tag")
public class TagController {

    @Autowired
    private TagService tagService;

    @ApiOperation(value = "新建标签")
    @PostMapping("/add")
    public String add(@RequestBody TagAddDTO tagAddDTO) {
        return tagService.add(tagAddDTO);
    }

    @ApiOperation(value = "修改标签")
    @PostMapping("/update")
    public void update(@RequestBody TagUpdateDTO tagUpdateDTO) {
        tagService.update(tagUpdateDTO);
    }

    @ApiOperation(value = "删除标签")
    @GetMapping("/delete")
    public void delete(@RequestParam String id) {
        tagService.delete(id);
    }

    @GetMapping("/list-mine")
    public List<TagListVO> list() {
        return tagService.listMine(MindUtils.getUserId());
    }
}

